﻿using Game;
namespace Mekiasm.Common
{
    public class AnimateBlockItem
    {
        public int x;
        public int y;
        public int z;
        public int FrameDuration;
        public AnimateModelItem item;
        public AnimateBlockItem(int xx, int yy, int zz, AnimateModelItem item1)
        {
            item = item1;
            x = xx;
            y = yy;
            z = zz;
            FrameDuration = 1;
        }
        public void Next()
        {
            int v = ILibrary.SubsystemTerrain.Terrain.GetCellValueFast(x, y, z);
            int rotate = ILibrary.getExtraData(v);
            if (Engine.Time.FrameIndex % FrameDuration == 0)
            {
                rotate = (rotate + 1) % item.MaxFrame;
                v = ILibrary.setExtraData(v, rotate);
                ILibrary.SubsystemTerrain.Terrain.SetCellValueFast(x, y, z, v);
                item.GenerateTerrainVertices(BlocksManager.Blocks[0], ILibrary.SubsystemTerrain.BlockGeometryGenerator, new TerrainGeometry(), v, x, y, z);
            }
        }

    }
}
